﻿using System;
using System.Diagnostics;
using Utils;

namespace StockAnalyst2.StockGrid
{
	[DebuggerDisplay("Name = {ColumnName}, Visible = {Visible}, DisplayIndex = {DisplayIndex}, NotifyChange = {NotifyChange}")]
	internal class ColumnOptions : PropertyChangedNotifier, ICloneable, IEquatable<ColumnOptions>
	{
		#region Attributes

		private bool _visible;
		private int _displayIndex;
		private bool _notifyChange;
		private bool _displayArrow;
		private bool _colorValue;
		private decimal _limit;

		#endregion

		#region Properties

		public string ColumnName { get; private set; }

		public bool Visible
		{
			get
			{
				return _visible;
			}
			set
			{
				if (_visible != value)
				{
					_visible = value;
					base.OnPropertyChanged("Visible");
				}
			}
		}

		public int DisplayIndex
		{
			get
			{
				return _displayIndex;
			}
			set
			{
				if (_displayIndex != value)
				{
					_displayIndex = value;
					base.OnPropertyChanged("DisplayIndex");
				}
			}
		}

		public bool NotifyChange
		{
			get
			{
				return _notifyChange;
			}
			set
			{
				if (_notifyChange != value)
				{
					_notifyChange = value;
					base.OnPropertyChanged("NotifyChange");
				}
			}
		}

		public bool DisplayArrow
		{
			get
			{
				return _displayArrow;
			}
			set
			{
				if (_displayArrow != value)
				{
					_displayArrow = value;
					base.OnPropertyChanged("DisplayArrow");
				}
			}
		}

		public bool ColorValue
		{
			get
			{
				return _colorValue;
			}
			set
			{
				if (_colorValue != value)
				{
					_colorValue = value;
					base.OnPropertyChanged("ColorValue");
				}
			}
		}

		public decimal Limit
		{
			get
			{
				return _limit;
			}
			set
			{
				if (_limit != value)
				{
					_limit = value;
					base.OnPropertyChanged("Limit");
				}
			}
		}

		#endregion

		#region Public Methods

		public ColumnOptions(string columnName)
		{
			this.ColumnName = columnName;
		}

		public void Copy(ColumnOptions other)
		{
			this.ColumnName = other.ColumnName;
			this.Visible = other.Visible;
			this.DisplayIndex = other.DisplayIndex;
			this.NotifyChange = other.NotifyChange;
			this.DisplayArrow = other.DisplayArrow;
			this.ColorValue = other.ColorValue;
			this.Limit = other.Limit;
		}

		#endregion

		#region ICloneable

		public object Clone()
		{
			return new ColumnOptions(this.ColumnName) { Visible = this.Visible, DisplayIndex = this.DisplayIndex, NotifyChange = this.NotifyChange, DisplayArrow = this.DisplayArrow, ColorValue = this.ColorValue, Limit = this.Limit};
		}

		#endregion

		#region IEquatable<ApplicationOptions>

		public bool Equals(ColumnOptions other)
		{
			return this.ColumnName == other.ColumnName && this.Visible == other.Visible && this.DisplayIndex == other.DisplayIndex && this.NotifyChange == other.NotifyChange && this.DisplayArrow == other.DisplayArrow && this.ColorValue == other.ColorValue && this.Limit == other.Limit;
		}

		#endregion
	}
}
